#include "qewidget.h"

QEWidget::QEWidget(bool HS,bool Position,int Colorset,QWidget * parent) : QWidget(parent), colorset(Colorset), halfSize(HS), oPosition(Position) {
}

QEWidget::~QEWidget(){}

void QEWidget::setColor(int Colorset){
    colorset=Colorset;
    update();
}

void QEWidget::setOSize(bool HS, bool oP){
    halfSize=HS;
    oPosition=oP;
    update();
}

void QEWidget::paintEvent(QPaintEvent * event) {
    //this->geometry().setWidth(474);

    if (!halfSize) {
        w = 456;
        x=(480-w)/2;
    }
    else {
        w= 446/2;
        if (!oPosition) x = (480-456)/2;
        else x= (480-456)/2+w+10;
    }

    setGeometry(x,y(),w, height());
    QPainter p(this);
    p.setRenderHint(QPainter::TextAntialiasing);
    p.setRenderHint(QPainter::Antialiasing);

    QLinearGradient black(0,0,0,height());
    QColor start(0,0,0,240);
    QColor end(0,0,0,120);
    black.setColorAt(0,start);
    black.setColorAt(1,end);

    switch (colorset) {
        case 0:
            p.setPen(Qt::transparent);
            p.setBrush(Qt::transparent);
            p.save();
            p.drawRect(0,0,width(),height());
            p.restore();
            break;
        case 1:
            p.setPen(Qt::NoPen);
            p.setBrush(black);
            p.save();
            p.drawRoundedRect(1,1,width()-2,height()-2, 10,10);
            p.restore();
            break;
        default :
            p.setPen(Qt::white);
            p.setBrush(Qt::white);
            p.save();
            p.drawRoundedRect(1,1,width()-2,height()-2, 10,10);
            p.restore();
            break;

    }

    p.end();
}
